package data;

import java.util.HashMap;
import java.util.Vector;

public class Forum {
	private int _id;
	private String _name;
	private HashMap <Integer, SubForum> _subForumColection;
	private Adminstrator _admin;
	private Integer _subForumIndex;
	
	public static Forum forum;
	
	public static Forum getForum()
	{
		if (forum == null)
			forum = new Forum(1, "genral", new Adminstrator());
		return forum;
	}
	
	public SubForum getSubForum(Integer index)
	{
		return this._subForumColection.get(index);
	}
	
	
	public Forum(int id, String name, Adminstrator admin) {
		super();
		_id = id;
		_name = name;
		_subForumColection= new HashMap<Integer, SubForum>();
		_subForumIndex=1;
		_admin=admin;
	}
	
	public String get_name() {
		return _name;
	}
	public void set_name(String name) {
		_name = name;
	}
	public int get_id() {
		return _id;
	}
	public HashMap<Integer, SubForum> get_subForumColection() {
		return _subForumColection;
	}

	public Adminstrator get_admin() {
		return _admin;
	}

	public void set_admin(Adminstrator admin) {
		_admin = admin;
	}
	
	public void addSubForum(String topic, Moderator moderators)
	{
		Integer index = this.get_subForumIndex();
		SubForum tempSubForum = new SubForum(index, topic, this, moderators);
		this._subForumColection.put(index, tempSubForum);
	}
	
	public void addSubForum(String topic, HashMap<Integer, Moderator> moderators)
	{
		Integer index = this.get_subForumIndex();
		SubForum tempSubForum = new SubForum(index, topic, this, moderators);
		this._subForumColection.put(index, tempSubForum);
	}

	public synchronized Integer get_subForumIndex() {
		Integer ans = new Integer(this._subForumIndex);
		_subForumIndex++;
		return ans;
	}
	
	
	
}
